package com.example.luozizhao.eprxdemo.http.cookie;

import android.text.TextUtils;
import android.util.Log;

import com.blankj.utilcode.util.SPUtils;
import com.example.luozizhao.eprxdemo.commom.Constant;

import java.io.IOException;
import java.util.HashSet;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by luozizhao on 2018/5/3.
 */

public class AddCookiesInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();
        String preferences = SPUtils.getInstance().getString(Constant.PREF_COOKIES);
        if (!TextUtils.isEmpty(preferences)) {
            builder.addHeader("Cookie",preferences);
        }
        return chain.proceed(builder.build());
    }
}